<form action="/svn/login/" method="post" id = "login_form">{% csrf_token %}
	{{ loginform.as_p }}
	<span class="label label-important" id="invalid_login" style="display: none">Invalid username and password combination.</span>
	<br>
	<input class="btn btn-primary" type="submit" value="Login"/>
	{% if allow_reg %}
		<button class="btn btn-info" type="button" id="register_login">Register</button>
	{% else %}
		<hr>
		<p>This application is not open for registration.</p>
	{% endif %}
	
</form>

<script>
	$('#login_form').submit(function(e){
		//var validlogin = false;
		$.ajax({
			type: "POST",
			url: "/svn/login/",
			data: $('#login_form').serialize(),
			success: function(msg){
				//window.location = msg
				if(msg=="LOGIN ERROR"){
					invalid_login_notice = document.getElementById('invalid_login');
					invalid_login_notice.style.display = 'block';
				}else{
					window.location = "/svn/"
				}
			}
		});
		//if(!validlogin)
		e.preventDefault();
	});
</script>